import  ViewBase  from '../../engine/ViewBase';
import { HttpHelper } from '../../net/HttpHelper';
import { UIHelper } from '../util/UIHelper';
const { ccclass, property } = cc._decorator;

@ccclass
export class ViewRegister extends ViewBase {

    private txtAccount: cc.EditBox
    private txtPass: cc.EditBox
    private txtPassAgain: cc.EditBox
    private btnQueding: cc.Node

    onEnable() {
        super.onEnable()
        this.txtAccount = this.getChild(this.node, "txtAccount", cc.EditBox)
        this.txtPass = this.getChild(this.node, "txtPass",cc.EditBox)
        this.txtPassAgain = this.getChild(this.node, "txtPassAgain", cc.EditBox)
        this.btnQueding = this.getChild(this.node, "btnQueding")
        UIHelper.onAddEvent(this.btnQueding, () => {
            if(this.txtAccount.string == ""){
                UIHelper.showTip("请输入账号!")
                return
            }
            if(this.txtPass.string == ""){
                UIHelper.showTip("请输入密码!")
                return
            }
            if(this.txtPass.string != this.txtPassAgain.string){
                UIHelper.showTip("2次密码不一样!")
                return
            }
            HttpHelper.accountReg(this.txtAccount.string, this.txtPass.string, (isSuc:boolean)=>{
                this.closeView()
            })
        })

    }
}

